#! /bin/bash

# for the plot_data() function.
. /home/bmort/Thesis/spectCleanGui/scripts/plotting/plot_data.sh

# Titles
# ------------------------------------------------------------------------------
t1="Time Series"
t2="Dirty Spectrum"
t3="Spectral Window"
t4="Clean Spectrum"

# Axis labels
# ------------------------------------------------------------------------------
xL1="Frequency [days^{-1}]"
xL2="Time [Julian Days]"
xL3="Periodicity [days]"
yL1="Signal Amplitude"
yL2="FT(z_{+} + z_{-})"
yL3="Amplitude"
yL4="Derived Speed [c]"

dirty=dirty_0.spect
clean=clean_residual_0.spect
window=window_0.spect


# Loop over bins and create plots
# ------------------------------------------------------------------------------
for i in `seq 0 15`
do
	dir=`pwd`/bin${i}
    echo ""
    echo "Creating plots for $dir"
    echo "====================================================================="
    if [ -d $dir ]; then
        if [ -f ${dir}/${dirty} ]; then
            plot_data "s" ${dir}/${dirty}  ${dir}/dirty  "$t2 (bin${i})" "$xL1" "$yL2" 0 0.5
            plot_data "s" ${dir}/${window} ${dir}/window "$t3 (bin${i})" "$xL1" "$yL3" 0 1.0
            plot_data "s" ${dir}/${clean}  ${dir}/clean  "$t4 (bin${i})" "$xL1" "$yL2" 0 0.5
            plot_data "p" ${dir}/${clean}  ${dir}/cleanP1  "$t4 (bin${i})" "$xL1" "$yL2" 2 30
            plot_data "p" ${dir}/${clean}  ${dir}/cleanP2  "$t4 (bin${i})" "$xL1" "$yL2" 5 20
            plot_data "p" ${dir}/${clean}  ${dir}/cleanP3  "$t4 (bin${i})" "$xL1" "$yL2" 10 15
        else 
            echo "*** empty directory... skipping"
        fi
    else 
        echo "*** directory doesnt exist... skipping"
    fi
done



